﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 泛型
{
    public class Temp<T>
    {
        public T m_a;
        public T m_b;
        public Temp(T a,T b)
        {
            m_a = a;
            m_b = b;
        }
    }
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            //泛型
            Temp<int> t = new Temp<int>(13,14);
            //容器
            //list
            var lst = new List<int>() { 3, 4, 5 };
            foreach(var i in lst)
            {
                Console.Write(i.ToString() + " ");
            }
            Console.WriteLine();
            //map
            var dict = new Dictionary<int, string>(){
                {3,"_3"},
                {5,"_5"},
            };
            foreach(var i in dict)
            {
                Console.Write("{0} , {1}",i.Key,i.Value);
            }
            Console.WriteLine();
            //set
            var set = new HashSet<int>(){
                3,4,5
            };
            if(set.Add(8))
            {
                Console.WriteLine("插入8成功");
            }
            if (set.Add(8))
            {
                Console.WriteLine("插入8成功");
            }
            else
            {
                Console.WriteLine("插入8失败");
            }
            //queue
            var que = new Queue<int>();
            que.Enqueue(1);//入队
            que.Enqueue(2);
            var item1 = que.Dequeue();//出队
            //stack
            var stack = new Stack<int>();
            stack.Push(1);//入栈
            var item2 =  stack.Pop();//出栈


            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());
        }
    }
}
